package smedi.ismedi.mobile.bff.controller.videomonitor;

import com.smedi.ismedi.video.monitor.api.dto.request.MonitorSettingUpdateRequest;
import com.smedi.ismedi.video.monitor.api.dto.response.MonitorSettingOrganizationResponse;
import com.smedi.ismedi.video.monitor.api.dto.response.MonitorSettingResponse;
import com.smedi.ismedi.video.monitor.api.feign.RemoteMonitorSettingFeignApi;
import com.smedi.ismedi.web.starter.common.PaginationData;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import smedi.ismedi.mobile.bff.controller.BaseController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/mobilebff/v1/video/monitor/monitorsetting")
@AllArgsConstructor
@Api(tags = "监控设置维护接口")
public class MonitorSettingController extends BaseController {
    private final RemoteMonitorSettingFeignApi remoteMonitorSettingFeignApi;

    /**
     * @param ids
     */
    @ApiOperation(value = "删除")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "ids", value = "监控设置id", dataType = "List"),
    })
    @DeleteMapping(value = "/doDelete")
    public ResponseData deleteMonitorSetting(@Validated @RequestBody List<Long> ids) {
        return remoteMonitorSettingFeignApi.deleteMonitorSetting(ids);
    }

    /**
     * @param offset
     * @param pageSize
     * @param equipmentName
     * @param serialNumber
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "监控设置信息查询")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "offset", value = "页码", dataType = "Long"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页行数", dataType = "Long"),
            @ApiImplicitParam(paramType = "query", name = "equipmentName", value = "设备名称", dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "serialNumber", value = "设备序列号", dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目id", dataType = "Long"),
    })
    @GetMapping(value = "/queryMonitorSetting")
    public ResponseData<PaginationData> getQueryAllMonitorSetting(@RequestParam("offset") Long offset,
                                                                  @RequestParam("pageSize") Long pageSize,
                                                                  @RequestParam(value = "equipmentName", required = false) String equipmentName,
                                                                  @RequestParam(value = "serialNumber", required = false) String serialNumber,
                                                                  @RequestParam("projectId") Long projectId,
                                                                  @RequestParam(value = "organizationId", required = false) Long organizationId
    ) {
        return remoteMonitorSettingFeignApi.getQueryAllMonitorSetting(offset, pageSize, equipmentName, serialNumber, projectId, organizationId);
    }

    /**
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "监控设置信息查询")
    @GetMapping(value = "/queryMonitorSettingTotal")
    ResponseData<List<MonitorSettingOrganizationResponse>> getQueryAllMonitorSettingTotal() {
        return remoteMonitorSettingFeignApi.getQueryAllMonitorSettingTotal();
    }

    /**
     * @param id
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "获取监控设置基本信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "id", value = "监控设置信息", dataType = "Long"),
    })
    @GetMapping(value = "/queryMonitorSettingInfo")
    public ResponseData<MonitorSettingResponse> getMonitorSettingInfo(@RequestParam("id") Long id) {
        return remoteMonitorSettingFeignApi.getMonitorSettingInfo(id);
    }

    /**
     * @param monitorSettingUpdateRequest
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "保存监控设置信息")
    @PostMapping(value = "/doSave")
    public ResponseData<MonitorSettingResponse> postSaveMonitorSetting(
            @RequestBody MonitorSettingUpdateRequest monitorSettingUpdateRequest) {
        return remoteMonitorSettingFeignApi.postSaveMonitorSetting(monitorSettingUpdateRequest);
    }
}
